<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<form action="<?php echo url_for('offer/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
          <?php echo $form->renderHiddenFields(false) ?>
          <input type="submit" value="Save" />
          <input type="submit" name="next" value="Save and add Images" />
          <input type="submit" name="next" value="Save and add Locations" />
          <br />
          &nbsp;<a href="<?php echo url_for('offer/index') ?>">Back to list</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'offer/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['site_id']->renderLabel() ?></th>
        <td>
          <?php echo $form['site_id']->renderError() ?>
          <?php echo $form['site_id'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['city_id']->renderLabel() ?></th>
        <td>
          <?php echo $form['city_id']->renderError() ?>
          <?php echo $form['city_id'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['name']->renderLabel() ?></th>
        <td>
          <?php echo $form['name']->renderError() ?>
          <?php echo $form['name']->render(array('class'=>'name')) ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['description']->renderLabel() ?></th>
        <td>
          <?php echo $form['description']->renderError() ?>
          <?php echo $form['description']->render(array('class'=>'description')) ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['url']->renderLabel() ?></th>
        <td>
          <?php echo $form['url']->renderError() ?>
          <?php echo $form['url'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['price']->renderLabel() ?></th>
        <td>
          <?php echo $form['price']->renderError() ?>
          <?php echo $form['price'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['full_price']->renderLabel() ?></th>
        <td>
          <?php echo $form['full_price']->renderError() ?>
          <?php echo $form['full_price'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['discount_percent']->renderLabel() ?></th>
        <td>
          <?php echo $form['discount_percent']->renderError() ?>
          <?php echo $form['discount_percent'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['remaining_time']->renderLabel() ?></th>
        <td>
          <?php echo $form['remaining_time']->renderError() ?>
          <?php echo $form['remaining_time'] ?>
        </td>
      </tr>
      <tr>
        <th>Valabil:</th>
        <td>
          <?php echo $form['start_time']->renderError() ?>
          <?php echo $form['end_time']->renderError() ?>
          <?php echo $form['start_time'] ?> - <?php echo $form['end_time'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['on_site']->renderLabel() ?></th>
        <td>
          <?php echo $form['on_site']->renderError() ?>
          <?php echo $form['on_site'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['promo']->renderLabel() ?></th>
        <td>
          <?php echo $form['promo']->renderError() ?>
          <?php echo $form['promo'] ?>
        </td>
      </tr>
    </tbody>
  </table>
</form>

<script>
  $(function() {
    $("#offer_start_time" ).datepicker();
    $("#offer_end_time" ).datepicker();
  });
</script>
